package com.example.trafficexam2.dao;

import android.content.Context;
import android.util.Log;

import com.example.trafficexam2.bean.Account;
import com.j256.ormlite.dao.Dao;

import java.sql.SQLException;
import java.util.List;

/**
 * Created by Administrator on 2018/11/23/023.
 */

public class AccountDao {
    private Context context;
    private Dao<Account, Integer> dao;
    private List<Account> users;
    public AccountDao(Context context){
        this.dao = DatabaseHelper.getInstance(context).getDao(Account.class);
    }
    public void insert(Account data) {
        try {
            dao.create(data);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public List<Account> queryByUsername(String username) {
        try {
            users = dao.queryBuilder().where().eq("operator",username).query();
            Log.e("TAG", "queryByUsername: ");
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return users;
    }

}
